package com.kgis.map.task.query {
   import com.kgis.flexutil.RemoteService;
   import com.kgis.flexutil.ServiceUtil;
   import com.kgis.map.Map;
   import com.kgis.map.RemoteCaller;
   import com.kgis.map.geometry.basetype.Extent;
   import com.kgis.map.layer.LayerData;

   import flash.external.ExternalInterface;
   import flash.net.getClassByAlias;
   import flash.net.registerClassAlias;
   import flash.utils.describeType;
   import flash.utils.getDefinitionByName;
   import flash.utils.getQualifiedClassName;

   import mx.controls.Alert;
   import mx.rpc.AsyncResponder;
   import mx.rpc.AsyncToken;
   import mx.rpc.events.FaultEvent;
   import mx.rpc.events.ResultEvent;
   import com.kgis.map.task.query.Query;

   /**
    * 通过logicalMapId和layerId查询图层数据
    */
   public class LayerLogicalMapIdQuery extends Query {
      //图层id
      private var _layerId:Number;
      //逻辑图id
      private var _logicalMapId:Number;

      private var _starttime:Date;

      public function LayerLogicalMapIdQuery(layerId:Number,logicalMapId:Number) {
         this._layerId = layerId;
         this._logicalMapId = logicalMapId;
         super("getLogicalMapData");
      }

      override public function execute():void {
         if (null == onResult)
            return;
         _starttime = new Date();

         var remoteCaller:RemoteCaller = new RemoteCaller("spatialDataManagementService")

         var token:AsyncToken = remoteCaller.remoteObject.getOperation(operationName).send(layerId, logicalMapId);
         token.addResponder(new AsyncResponder(onQueryResult, onQueryFault));

      }

      /**根据图层id和地图范围获取 矢量设施数据*/
      private function onQueryResult(event:ResultEvent, token:Object = null):void {
         var layerData:LayerData = event.result as LayerData;
         trace("logicallayerid:" + layerId.toString() + ",remote请求耗时:" + ((new Date()).getTime() - _starttime.getTime()).toString());
         onResult(layerData, token);
      }

      public function get layerId():Number {
         return _layerId;
      }

      public function set layerId(value:Number):void {
         _layerId = value;
      }

      public function get logicalMapId():Number {
         return _logicalMapId;
      }

      public function set logicalMapId(value:Number):void {
         _logicalMapId = value;
      }


   }
}